var path="/cmyfepms2";
/**
 *全选的时候,只能够删除记录
*/
function checkedAll(obj){ 
  var m = document.getElementsByName("entityId");
  var entityIds = document.getElementById("entityIds");
  var checkNum = document.getElementById("checkNum");
  entityIds.value = "";
  checkNum.value = 0; 
  for ( var i=0; i<m.length; i++){
     if(obj.checked){
       m[i].checked = true;
       entityIds.value = entityIds.value+m[i].value + ",";
       checkNum.value++;
     } else {
       m[i].checked = false;
       entityIds.value = "";
     }            
   }
}

/**
 *选择一条记录时,可以删除,修改,变更等操作;
 *选择多条记录时,只能删除记录;
 *选择记录后还要通过记录的状态进行判断是否有相关的操作;
 */
function checkedBox(obj){ 
  var m = document.getElementsByName("entityId");
  var entityIds = document.getElementById("entityIds");
  var checkNum = document.getElementById("checkNum");
   
  entityIds.value="";
  checkNum.value = 0; 
 
  for ( var i=0; i< m.length; i++){
      if(m[i].checked){
        checkNum.value++;
        entityIds.value = entityIds.value+m[i].value + ",";
      } 
  }
}
function Action(method, actionPath){
	if(method == "new"){
	  	 this.location=actionPath + "?method=create";
	  	 return;
	}

	//checkedBox();
  var entityIds = document.getElementById("entityIds");
  var checkNum = document.getElementById("checkNum"); 
  var id = entityIds.value;
 
  if(id != ""){id = id.substring(0, id.length - 1);}

 if(method == "del"){
     if(id == "") {alert("请选择要删除的记录!");return false;}
     if(confirm("请确认删除!")){
     	this.location=actionPath + "?method=delete&ids=" + id; 
     }  
  } else if(method == "edit"){
  	 if(id == "") {alert("请选择要修改的记录!");return false;}
     if(checkNum.value != "1") {alert("只能选择一条记录!");return false;}
  	 this.location=actionPath + "?method=edit&id=" + id;
  } else if(method == "view"){
     if(id == "") {alert("请选择要查看的记录!");return false;}
     if(checkNum.value != "1") {alert("只能选择一条记录!");return false;}
  	 this.location=actionPath + "?method=view&id=" + id;
  }
}

/*显示或隐藏搜索条件栏*/
function dispSearchDiv(obj){
  var src = obj.src;
  src = src.substring(src.length-9,src.length);
  
  if(src=="tag10.gif"){
     obj.src="../images/portal/style/green/tag11.gif";
     var searchDiv = document.getElementById("searchDiv");
     searchDiv.style.display = "none"; 
  } else {
     obj.src="../images/portal/style/green/tag10.gif";
     var searchDiv = document.getElementById("searchDiv");
     searchDiv.style.display = "block"; 
  }
}

/*清空表单*/
function refresh(form){ 
	var v = form.elements; 
	for(var i=0;i<v.length;i++){ 
		if(v[i].type=="text" || v[i].type == "select"){ 
			v[i].value = ""; 
		} 
	}
} 

/**选择部门 多选*/
function branchSel(s1,s2,s3)
{
	showModalDialog(path+'/pages/admin/branchselect.jsp?fieldName='+s1+'&fieldId='+s2+'&formName='+s3,window,'dialogWidth:540px;dialogHeight:430px;center:yes;help:yes;resizable:no;status:no;scroll:no');
}
/**选择部门 单选*/
function branchOneSel(s1,s2,s3)
{
	showModalDialog(path+'/pages/admin/branchselect.jsp?oneSel=true&fieldName='+s1+'&fieldId='+s2+'&formName='+s3,window,'dialogWidth:540px;dialogHeight:430px;center:yes;help:yes;resizable:no;status:no;scroll:no');
}
/**选择人员 多选*/
function userSel(s1,s2,s3)
{
	showModalDialog(path+'/pages/admin/userselect.jsp?fieldName='+s1+'&fieldId='+s2+'&formName='+s3,window,'dialogWidth:540px;dialogHeight:430px;center:yes;help:yes;resizable:no;status:no;scroll:no');
}
/**选择人员 单选*/
function userOneSel(s1,s2,s3)
{
	showModalDialog(path+'/pages/admin/userselect.jsp?oneSel=true&fieldName='+s1+'&fieldId='+s2+'&formName='+s3,window,'dialogWidth:540px;dialogHeight:430px;center:yes;help:yes;resizable:no;status:no;scroll:no');
}

/**选择项目 多选*/
function projectSel(s1,s2,s3)
{
	showModalDialog(path+'/InvestmentProjectAction.do?method=selProject&fieldName='+s1+'&fieldId='+s2+'&formName='+s3,window,'dialogWidth:540px;dialogHeight:430px;center:yes;help:yes;resizable:no;status:no;scroll:no');
}

/**选择项目 多选*/
function projectSelOne(s1,s2,s3) {
	var url = path+'/InvestmentProjectAction.do?method=selProject&type=one&fieldName='+s1+'&fieldId='+s2+'&formName='+s3;
	//alert(url);
	showModalDialog(url,window,'dialogWidth:540px;dialogHeight:430px;center:yes;help:yes;resizable:no;status:no;scroll:no');
}
/* 
* 判断是否为数字(含小数)，是则返回true,否则返回false 
*/ 
function f_check_number(obj)    
{           
    if ( /^[0-9]+.?[0-9]*$/.test(obj.value))    
    {    
       return true;    
    }     
    else     
    {    
       return false;    
    }    
} 
/* 
* 判断是否为数字(整数)，是则返回true,否则返回false 
*/ 
function f_check_number_int(obj)    
{           
    if (/^\d+$/.test(obj.value))    
    {    
       return true;    
    }     
    else     
    {    
       return false;    
    }    
}



   /*
  *上传附件
  *s表示框架名称,fromTab表示表名
  */
  function doUpfile(s,fromTab)
  {
  
    //取消上传
    var submitButton = document.getElementById("upFileButton");
    var submitButtonValue = submitButton.value;
    if(submitButtonValue=="取消上传")
    {
      if(window.confirm('文件还没上传完成！确定要放弃吗？'))
      {
          submitButton.value = "上传附件";
          s.refersh.submit();
      }
     return true;
    }
   
	s.annexForm.upfile.click() != '';
	file_arr=s.annexForm.upfile.value.split('.');
	if(s.annexForm.upfile.value=="")
	{
	 return false;
	}
	/**设置进度条宽度*/
     //divprogressBarBox = s.document.getElementById("progressBarBox");
     //divprogressBarBox.style.height=s.style.height;
  
	filetype=file_arr[file_arr.length-1];
	if (filetype == "java" || filetype == "jsp" || filetype == "php" || filetype == "php3" || filetype == "php4" || filetype == "html" || filetype == "htm" || filetype == "js" )
	{
		alert("请重新选择文件, 文件类型错误!");
		return false;
	}
	//s.startProgress('files','save')
	s.annexForm.method.value  = "save";
	s.annexForm.fromTab.value = fromTab;
	s.annexForm.savebtn.value = "save";
	s.annexForm.submit();
	
	//startProgress('s.annexForm.upfile','save')
  }     
 
function outputMoney(number) { 
	number=number.replace(/\,/g,"");
	if (isNaN(number)||number=="") return ""; 
	return number;
} 

/*
用途：检查输入字符串是否是带小数的数字格式,可以是负数
输入：
 s：字符串
返回：
 如果通过验证返回true,否则返回false 
*/
function isDecimal( str ){   
 if(isInteger(str)) return true;
 var re = /^[-]{0,1}(\d+)[\.]+(\d+)$/;
 if (re.test(str)) {
    if(RegExp.$1==0&&RegExp.$2==0) return false;
    return true;
 } else {
    return false;
 }
}

/*
用途：检查输入对象的值是否符合整数格式
输入：str 输入的字符串
返回：如果通过验证返回true,否则返回false 
*/
function isInteger( str ){  
 var regu = /^[-]{0,1}[0-9]{1,}$/;
 return regu.test(str);
}

/*
用途：检查输入字符串是否是带小数的数字格式,可以是负数(并且满足规定的精度)
输入：str：字符串
            l：总位数
           d：小数点后位数
返回：
 如果通过验证返回true,否则返回false 
*/
function isDecimal2( str,l,d ){   
         if(isInteger(str)) {
    if (l==null)  return true;
    if (str<0) l--;
      if (str.length<=l) return true;
         }

         var re = /^[-]{0,1}(\d+)[\.]+(\d+)$/;
       if (re.test(str)) {
  if (l==null)  return true;
  if (d==null) d=0;
        if(RegExp.$1==0&&RegExp.$2==0) return false;
  if (RegExp.$1.length+RegExp.$2.length<=l
   && RegExp.$2.length<=d)  return true;
    }
 return false;
}

function isWinClose(){
  return confirm("是否保存数据");
}
  